package com.spring.demo6.eg5;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @author vhans
 */
@Component
public class InjectService2 {

    private IService service1;

    private IService service2;

    // @Qualifier在方法参数中标注要注入的具体bean
    @Autowired
    public void injectBean(@Qualifier("service1") IService s1, @Qualifier("service2") IService s2) {
        this.service1 = s1;
        this.service2 = s2;
    }

    @Override
    public String toString() {
        return "InjectService2{" +
                "service1=" + service1 +
                ", service2=" + service2 +
                '}';
    }
}
